package com.moli.iov.base.util;

import com.moli.iov.exception.BusinessException;
import com.moli.iov.rest.RestResponse;
import lombok.extern.slf4j.Slf4j;

/**
 * 服务验证
 *
 * @author wanghualin
 * @date 2019 -10-28 10:50:21
 */
@Slf4j
public class ServiceValidation {

  /**
   * @param serviceName 服务名称
   */
  public static void validationService(RestResponse response, String serviceName) {
    if (response == null) {
      log.info(serviceName + ":" + "服务调用失败");
     throw    new BusinessException(serviceName + ":服务调用失败");
    }
    if (!response.isFlag()) {
      log.info(serviceName + ":" + "服务调用失败");
      throw   new BusinessException(serviceName + ":" + response.message);
    }
  }
}
